type Deck = NormalCard[];
enum Color {
  heart = "♥",
  spade = "♠",
  club = "♣",
  diamod = "♦",
}

enum Mark {
  A = "A",
  two = "2",
  three = "3",
  four = "4",
  five = "5",
  six = "6",
  seven = "7",
  eight = "8",
  nine = "9",
  ten = "10",
  eleven = "J",
  twelve = "Q",
  king = "K",
}

type NormalCard = {
  color: Color;
  mark: Mark;
};

function createDeck(): Deck {
  const deck: Deck = [];

  const marks = Object.values(Mark); // Object.values()会运行才能知道marks，而在运行过程中ts会被删除，因此此时这里为any类型
  const colors = Object.values(Color);

  for (const m of marks) {
    for (const c of colors) {
      deck.push({
        mark: m,
        color: c,
      });
    }
  }

  return deck;
}

function printDeck(deck: Deck) {
  let result = "\n";
  deck.forEach((card, i) => {
    result += card.color + card.mark + "\t";
    if ((i + 1) % 6 === 0) {
      result += "\n";
    }
  });
  console.log(result);
}

const deck = createDeck();
printDeck(deck);

export {};
